<template>
  <div>
    <div class="m-top">
      <div class="wrap">
        <h1 class="h1_logo" @click="$router.push('/'), (active = 0)"></h1>
        <ul class="m-nav">
          <li
            v-for="(item, i) in navData"
            :key="i"
            :class="{ active: active === i }"
            @click="$router.push({ path: item.path }), (active = i)"
          >
            {{ item.name }}
          </li>
          <li class="pr">
            下载客户端
            <i class="hot"></i>
          </li>
        </ul>
        <div class="login"><router-link to="/login">登录</router-link></div>
        <div class="login"><router-link to="/register">注册</router-link></div>
        <a href="#" class="creator">创作者中心</a>
        <div class="music-search">
          <input type="text" placeholder="音乐/视频/电台/用户" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  watch: {},
  data() {
    return {
      active: 0,
      navData: [
        { name: "发现音乐", path: "/" },
        { name: "我的音乐", path: "/myMusic" },
        { name: "歌手", path: "/musicPlayer" },
        { name: "歌单", path: "/musicList" },
        { name: "音乐人", path: "/" },
      ],
    };
  },
  methods: {
    // 点击跳转主页
    home() {
      this.$router.push("/");
    },
    // 点击跳转我的音乐
    myMusic() {
      this.$router.push("/myMusic");
    },
    musicPlayer() {
      this.$router.push("/musicPlayer");
    },
  },
};
</script>

<style lang="scss" scoped>
body {
  background-color: #f2f2f2;
}

.m-top {
  width: auto;
  height: 70px;
  background: #242424;
}

.m-top .wrap {
  width: 1100px;
  margin: 0 auto;
  height: 70px;
}

.h1_logo {
  cursor: pointer;
  float: left;
  width: 176px;
  height: 69px;
  background-position: 0 0;
  background-image: url(../assets/images/topbar.png);
  background-repeat: no-repeat;
}

.m-top .m-nav {
  float: left;
}

.m-top .m-nav li {
  float: left;
  height: 70px;
  line-height: 70px;
  color: #ccc;
  padding: 0 19px;
  cursor: pointer;
}
.active {
  background-color: #000;
  color: #fff;
}
.m-top .m-nav li:hover {
  background-color: #000;
  color: #fff;
}

.hot {
  display: block;
  position: absolute;
  top: 21px;
  left: 100px;
  width: 28px;
  height: 19px;
  background-position: -190px 0;
  background-image: url(../assets/images/topbar.png);
  background-repeat: no-repeat;
}

.m-top .music-search {
  width: 158px;
  height: 32px;
  float: right;
  margin-top: 19px;
  background-position: 0 -99px;
  background-color: #fff;
  border-radius: 32px;
  background-image: url(../assets/images/topbar.png);
  background-repeat: no-repeat;
  position: relative;
}

.m-top .music-search input {
  width: 75%;
  margin: 0;
  padding: 0;
  background: transparent;
  line-height: 16px;
  border: 0;
  margin: 7px 0 0 30px;
  font-size: 12px;
  color: #ccc;
}

.m-top .creator {
  width: 90px;
  height: 32px;
  float: right;
  margin: 19px 0 0 12px;
  padding-left: 16px;
  box-sizing: border-box;
  border: 1px solid #4f4f4f;
  line-height: 33px;
  color: #ccc;
  border-radius: 20px;
  font-size: 12px;
}

.m-top .creator:hover {
  border: 1px solid #fff;
  color: #fff;
}

.m-top .login {
  float: right;
  height: 45px;
  margin: 27px 0 0 20px;
  padding: 0 22px 0 0;
  font-size: 12px;
}

.m-top .login a {
  color: #787878;
  display: block;
  text-decoration: none;
}

.m-top .login a:hover {
  color: #ccc;
}
</style>